
const routes = [
  {
    path: '/sign/in',
    name: 'signIn',
    components: {
        'header': () => import('../components/HeaderView.vue'),
        'middle': () => import('../components/SignInView.vue'),
        'footer': () => import('../components/FooterView.vue')
    },
    meta: {
        title: '用户登录'
    }
  },
  {
    path: '/sign/up',
    name: 'signUp',
    components: {
        'header': () => import('../components/HeaderView.vue'),
        'middle': () => import('../components/SignUpView.vue'),
        'footer': () => import('../components/FooterView.vue')
    },
    meta: {
        title: '用户注册'
    }
  },
  {
    path: '/sign/out',
    name: 'signOut',
    beforeEnter: (to,from)=>{
      // 从 sessionStorage 中删除认证信息
      sessionStorage.removeItem( 'token' );
      // 终止当前导航并去往登录页面
      return { name: 'signIn' }
    }
  },
  {
    path: '/list',
    name: 'list',
    components: {
        'header': () => import('../components/HeaderView.vue'),
        'middle': () => import('../components/ListView.vue'),
        'footer': () => import('../components/FooterView.vue')
    },
    meta: {
        title: '用户列表'
    }
  },
  {
    path: '/add',
    name: 'add',
    components: {
        'header': () => import('../components/HeaderView.vue'),
        'middle': () => import('../components/AddView.vue'),
        'footer': () => import('../components/FooterView.vue')
    },
    meta: {
        title: '新增用户'
    }
  },
  {
    path: '/set',
    name: 'set',
    components: {
        'header': () => import('../components/HeaderView.vue'),
        'middle': () => import('../components/SettingsView.vue'),
        'footer': () => import('../components/FooterView.vue')
    },
    meta: {
        title: '个人设置'
    }
  },
];

export default routes ;